﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Medianamik.Core;
using Medianamik.Core.Profile;
using Medianamik.Core.Querying;
using Medianamik.Core.Security;
using Medianamik.UI.Controls;
using Telerik.Web.UI;

namespace Medianamik.UI.Web.Forum
{
    public partial class ForumUserList : BaseModuleListPage
    {




        protected override void GridNeedDataSource(object source, GridNeedDataSourceEventArgs e)
        {
            Grid.DataSource = new Query()
                 .Where(n => n.ParentID, Comparison.Equal, RootNodeId)
                 .Where(n => n.NodeTypeID, Comparison.Equal, MedianamikTypes.MedianamikProfile)
                 .Where(MedianamikProperties.ProfileUser, Comparison.In, SecurityManager.GetUsersInGroups(FilteredGroups))
                 .AsQuery<ProfileNode>().Execute();
        }

        protected override string ReturnUrl
        {
            get { return "/medianamik/forum/ForumUserList.aspx"; }
        }

        protected override Guid RootNodeId
        {
            get { return MedianamikModules.SecurityManagement; }
        }

        protected override RadGrid Grid
        {
            get { return ForumUserGrid; }
        }

        protected override UpdatePanel GridUpdatePanel
        {
            get { return ForumUserUpdatePanel; }
        }

        protected override string ManagementURL
        {
            get { return "forumusermanagement.aspx"; }
        }

        protected override GridOptions GridOptions
        {
            get
            {
                return GridOptions.None;
            }
        }

        protected virtual HashSet<String> FilteredGroups
        {
            get
            {
                return new HashSet<string>(new[] { "Blogger", "Commentator" });
            }
        }



        protected override void Navigate()
        {
            base.Navigate();
            Grid.Rebind();
            ForumUserUpdatePanel.Update();
        }

    }
}
